/*
// Exepack.NET
// http://www.codeplex.com/exepack
//
// Deflate utility
// Written by Y [10-01-09]
// Copyright (c) 2008-2010 Alexey Yakovlev
*/

using System;
using System.IO;
using System.IO.Compression;

class Deflater
{
	static void Main(string[] args)
	{
		if (args.Length != 2)
		{
			Console.WriteLine("syntax: deflate infile outfile");
			return;
		}

		using (FileStream inFile = File.OpenRead(args[0]))
		using (FileStream outFile = File.Create(args[1]))
		using (DeflateStream ds = new DeflateStream(outFile, CompressionMode.Compress))
		{
			var w = new BinaryWriter(outFile);
			w.Write((uint)inFile.Length);
			w.Flush();

			w = new BinaryWriter(ds);
			w.Write(new BinaryReader(inFile).ReadBytes((int)inFile.Length));
			w.Flush();
		}
	}
}
